#-*- codeing = utf-8 -*-
#@Time : 2020/8/7 14:20
#@Author : 阳某
#@File : testjsonpath.py
#@Software : PyCharm
from jsonpath import jsonpath
import requests
from fake_useragent import UserAgent
import json
url = 'https://www.lagou.com/lbs/getAllCitySearchLabels.json'
headers = {
    "User-Agent":UserAgent().chrome
}
response = requests.get(url,headers = headers)
print(response.status_code)
str = response.text
json_str = json.loads(str)      #json对象
names = jsonpath(json_str,'$..name')
# codes = jsonpath(json_str,'$..code')
codes = jsonpath(response.json(),'$..code')
print(names)
print(codes)




